﻿<%@ Page Title="" Language="C#" MasterPageFile="~/PBOfficeMaster.master" AutoEventWireup="true"
    CodeFile="RoleUser.aspx.cs" Inherits="SystemManager_RoleUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link type="text/css" rel="Stylesheet" href="../css/SystemManagerCss.css" />
    <style type="text/css">
        .tree
        {
            text-align: left;
        }
    </style>
    <script type="text/javascript" src="../js/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" language="javascript">
        function tree_oncheck(tree) {
            var node = tree.getTreeNode(tree.clickedNodeIndex);
            var Pchecked = node.getAttribute("checked");
            alert(Pchecked);
            var inde = node.getNodeIndex();
            if (inde != null) {
                tree.queueEvent('oncheck', node.getNodeIndex());
            }
            setcheck(node, Pchecked, tree);
            setParentCheck(node, tree, Pchecked);
        }
        //父节点操作
        function setParentCheck(node, tree, pchecked) {
            var tempNode;
            tempNode = node.getParent();
            if (tempNode != null) {
                var inde = tempNode.getNodeIndex();
                if (inde != null && pchecked) {
                    var axz = tempNode.getAttribute("checked");
                    if (!axz) {
                        tempNode.setAttribute("Checked", "true");
                        tree.queueEvent('oncheck', tempNode.getNodeIndex());
                    }
                    setParentCheck(tempNode, tree, pchecked);
                }
            }
        }
        //子节点操作
        function setcheck(node, Pc, t) {
            var ChildNode = new Array();
            ChildNode = node.getChildren();
            if (parseInt(ChildNode.length) != 0) {
                for (var i = 0; i < ChildNode.length; i++) {
                    var cNode = ChildNode[i];
                    var inde = cNode.getNodeIndex();
                    var axz = cNode.getAttribute("checked");
                    if (inde != null && axz != Pc) {
                        cNode.setAttribute("checked", Pc);
                        t.queueEvent('oncheck', inde);
                        if (parseInt(cNode.getChildren().length) != 0)
                            setcheck(cNode, Pc, t);
                    }
                }
            }
        } 
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div style="width: 864px;">
        <div class="branchtop">
            <table>
                <tr>
                    <td>
                        当前位置
                    </td>
                    <td>
                        <div class="lbBranch">
                            角色用户</div>
                    </td>
                </tr>
            </table>
        </div>
        <hr />
        <div style="float: left;">
            <div style="float: left; margin-left: 70PX; height: 500px; width: 180px;">
                <asp:TreeView ID="TreeView1" CssClass="tree" runat="server" ExpandDepth="0" ShowCheckBoxes="All">
                    <NodeStyle ChildNodesPadding="5px" Font-Size="12px" />
                </asp:TreeView>
            </div>
            <div style="float: left; text-align: left; margin: 100PX 100PX;">
                <asp:Button ID="btnSave" CssClass="btnBranch" runat="server" Text="保存设置" Height="35px"
                    OnClick="btnSave_Click" /></div>
        </div>
    </div>
</asp:Content>
